/*
 * Licensed to the Tai Ping Jin Ke
 *
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称：呼叫中心-通用处理层-任务调度
 * 版权说明：本软件属太平金融科技服务(上海)有限公司所有，在未获得太平金融科技服务(上海)有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.taiping.cc.job.converter;

import cn.hutool.core.util.IdUtil;
import com.taiping.cc.application.constant.dao.ConfigStatusEnum;
import com.taiping.cc.application.constant.service.PlatformServiceEnum;
import com.taiping.cc.job.dataobject.HttpResponseConfigDO;
import com.taipingframework.utility.exception.ManagerException;
import com.taipingframework.utility.http.ServiceConfigInfo.ServiceResponseConfigInfo;

public class HttpResponseConfigConverter {

    /**
     * ServiceResponseConfigInfo数据传输对象 转 HttpResponseConfigDO数据对象
     */
    public static HttpResponseConfigDO convert(PlatformServiceEnum serviceConstant, ServiceResponseConfigInfo responseConfigInfo) throws ManagerException {
        HttpResponseConfigDO responseConfig = new HttpResponseConfigDO();
        responseConfig.setResponseId(IdUtil.objectId());
        responseConfig.setPlatformCode(serviceConstant.getPlatformCode());
        responseConfig.setPlatformName(null);
        responseConfig.setServiceCode(serviceConstant.getServiceCode());
        responseConfig.setServiceName(null);
        responseConfig.setRootMapPath(responseConfigInfo.getRootMapPath());
        responseConfig.setBatchReturn(responseConfigInfo.getBatchReturn().getCode());
        responseConfig.setCurrentPageKey(responseConfigInfo.getCurrentPageKey());
        responseConfig.setTotalPageKey(responseConfigInfo.getTotalPageKey());
        responseConfig.setStartPageNo(responseConfigInfo.getStartPageNo());
        responseConfig.setDataParseType(responseConfigInfo.getDataParseType().getCode());
        responseConfig.setResponseBodyDataType(responseConfigInfo.getResponseBodyDataType().getCode());
        responseConfig.setDecryptKey(responseConfigInfo.getDecryptKey());
        responseConfig.setConfigStatus(ConfigStatusEnum.ENABLE.getCode());
        responseConfig.setRemark(null);
        BaseDataObjectConverter.convert(responseConfig);
        return responseConfig;
    }

}
